<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Orders extends Model
{
    use HasFactory;
    use SoftDeletes;
    protected  $guarded = [];
    protected $table = 'order';

    public function visit()
    {
        return $this->hasOne(Visits::class,'user_id','user_id');
    }

    public static function getOrderIndex($where = null)
    {
        return self::with('visit')->when($where, function($query) use ($where){
           return $query->where($where);
        })->get();
    }
}
